<!DOCTYPE html>
<html  lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>删除宿舍房间</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-4">
    <div class="card">
        <div class="card-header bg-danger text-white">
            <h4>确认删除宿舍房间</h4>
        </div>
        <div class="card-body">
            <div th:if="${dormRoom} == null" class="alert alert-danger">
                未找到指定的宿舍房间！
            </div>

            <div th:if="${dormRoom} != null">
                <h5>您确定要删除以下宿舍房间吗？</h5>
                <hr>
                <p><strong>宿舍楼：</strong> <span th:text="${dormRoom.building.buildingName}"></span></p>
                <p><strong>房间号：</strong> <span th:text="${dormRoom.roomNumber}"></span></p>
                <p><strong>房间类型：</strong> <span th:text="${dormRoom.type.typeName}"></span></p>
                <p><strong>当前人数：</strong> <span th:text="${dormRoom.currentCapacity}"></span>/<span th:text="${dormRoom.maxCapacity}"></span></p>
                <p><strong>状态：</strong> <span th:text="${dormRoom.status}"></span></p>

                <div th:if="${not #lists.isEmpty(dormRoom.students)}" class="alert alert-warning mt-3">
                    <strong>警告：</strong> 该房间当前有 <span th:text="${dormRoom.students.size()}"></span> 名学生入住，删除房间将同时移除这些学生的住宿信息！
                </div>

                <form th:action="@{/dormrooms/delete/} + ${dormRoom.id}" method="post">
                    <input type="hidden" name="_method" value="delete">
                    <button type="submit" class="btn btn-danger">确认删除</button>
                    <a th:href="@{/dormrooms/list}" class="btn btn-secondary">取消</a>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>